# coding=utf-8
from comment.modules import db
from sqlalchemy import ForeignKey
from datetime import datetime

class Letter(db.Model):
    '''收发消息的模型类'''
    __tablename__ = 't_letter'
    id = db.Column(db.BIGINT, primary_key=True, autoincrement=True)
    sendID = db.Column(db.String(64), comment='发送者名字')
    recID = db.Column(db.BIGINT, comment='接受者ID')
    detail_id = db.Column(db.BIGINT, ForeignKey('t_letter_detail.id'), comment='消息详情主键')
    letter_detail = db.relationship('Letter_Detail', backref=db.backref('letter', lazy=True))
    state = db.Column(db.Integer, comment='持否已读（0未读；1已读）')

class Letter_Detail(db.Model):
    '''消息详细的模型类，他和收发消息的模型类是一对多的关联关系'''
    __tablename__ = 't_letter_detail'
    id = db.Column(db.BIGINT, primary_key=True, autoincrement=True)
    title = db.Column(db.String(64), comment='消息标题')
    detail = db.Column(db.String(256), comment='消息内容')
    pDate = db.Column(db.DateTime, default=datetime.now(), comment='发送时间')














